namespace QMVnSoft.Invoices
{
    using QMVnSoft;
    using QMVnSoft.Controls;
    using QMVnSoft.Controls.ChildGridControls;
    using QMVnSoft.DAL;
    using System;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Windows.Forms;

    public class FormProductCosting : FormControl
    {
        private BtnControl btnControl2;
        private BtnControl btnControl3;
        private BtnControl btnControl4;
        private DataGridViewTextBoxColumn Column1;
        private NumericColumn Column10;
        private DataGridViewTextBoxColumn Column11;
        private NumericColumn Column12;
        private NumericColumn Column13;
        private NumericColumn Column14;
        private NumericColumn Column15;
        private NumericColumn Column16;
        private DataGridViewTextBoxColumn Column2;
        private NumericColumn Column3;
        private NumericColumn Column4;
        private NumericColumn Column5;
        private NumericColumn Column6;
        private NumericColumn Column7;
        private NumericColumn Column8;
        private NumericColumn Column9;
        private IContainer components;
        private GridControl grdDetail;
        private GridControl grdMaster;
        private decimal ii_NewValue;
        private decimal ii_OldValue;
        private int ii_RowMasterIndex;
        private LabelControl labelControl1;
        private LabelControl lblMa_Sp;
        private DmPBSPDataAccess oMethod;
        private object oUserDefined1;
        private object oUserDefined2;
        private object oUserDefined3;
        private object oUserDefined4;
        private SplitContainer splitContainer1;
        private TextSearch txtMa_Sp;
        private TextControl txtTen_Sp;

        public FormProductCosting()
        {
            this.oMethod = new DmPBSPDataAccess();
            this.ii_RowMasterIndex = -1;
            this.InitializeComponent();
        }

        public FormProductCosting(object poUserDefined1, object poUserDefined2, object poUserDefined3, object poUserDefined4)
        {
            this.oMethod = new DmPBSPDataAccess();
            this.ii_RowMasterIndex = -1;
            this.InitializeComponent();
            this.grdMaster.AutoGenerateColumns = false;
            this.grdDetail.AutoGenerateColumns = false;
            this.UserDefined1 = poUserDefined1;
            this.UserDefined2 = poUserDefined2;
            this.UserDefined3 = poUserDefined3;
            this.UserDefined4 = poUserDefined4;
        }

        private void btnControl2_Click(object sender, EventArgs e)
        {
            if ((((DateTime) this.UserDefined2) < AppInstance.OpeningDateOfSubEnterprice) || (((DateTime) this.UserDefined2) <= AppInstance.EndingDateOfSubEnterprice))
            {
                MessageBox.Show("Đã khóa dữ liệu!", AppInstance.SoftwareName, MessageBoxButtons.OK, MessageBoxIcon.Hand);
            }
            else if (MessageBox.Show("Chắc chắn xóa to\x00e0n bộ chi tiết phân bổ không?", AppInstance.SoftwareName, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                this.oMethod.PhanBo_Delete_All(AppInstance.Subsidiary, this.UserDefined1, this.UserDefined2, this.txtMa_Sp.Value);
            }
        }

        private void btnControl3_Click(object sender, EventArgs e)
        {
            if ((((DateTime) this.UserDefined2) < AppInstance.OpeningDateOfSubEnterprice) || (((DateTime) this.UserDefined2) <= AppInstance.EndingDateOfSubEnterprice))
            {
                MessageBox.Show("Đã khóa dữ liệu!", AppInstance.SoftwareName, MessageBoxButtons.OK, MessageBoxIcon.Hand);
            }
            else
            {
                this.oMethod.UpdateProductCosting(AppInstance.Subsidiary, this.UserDefined1, this.UserDefined2, this.txtMa_Sp.Value, this.UserDefined3);
                MessageBox.Show(AppInstance.EndMessage, AppInstance.SoftwareName, MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
        }

        private void btnControl4_Click(object sender, EventArgs e)
        {
            DataTable dataSource = this.oMethod.GetMasterTable(AppInstance.Subsidiaries, this.UserDefined1, this.UserDefined2, this.txtMa_Sp.Value);
            this.grdMaster.DataSource = new BindingSource(dataSource, dataSource.TableName);
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void grdDetail_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)
        {
            this.ii_OldValue = (decimal) ((DataRowView) this.grdDetail.Rows[e.RowIndex].DataBoundItem).Row["Du_Cuoi"];
        }

        private void grdDetail_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            this.ii_NewValue = (decimal) ((DataRowView) this.grdDetail.Rows[e.RowIndex].DataBoundItem).Row["Du_Cuoi"];
            if ((e.ColumnIndex == 5) && (this.ii_OldValue != this.ii_NewValue))
            {
                if (MessageBox.Show("Điều chỉnh giá trị sản phẩm dở dang?", AppInstance.SoftwareName, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    ((DataRowView) this.grdMaster.CurrentRow.DataBoundItem).Row["Ps_Co"] = (((decimal) ((DataRowView) this.grdMaster.CurrentRow.DataBoundItem).Row["Ps_Co"]) + this.ii_OldValue) - this.ii_NewValue;
                    ((DataRowView) this.grdMaster.CurrentRow.DataBoundItem).Row["Du_Cuoi"] = (((decimal) ((DataRowView) this.grdMaster.CurrentRow.DataBoundItem).Row["Du_Cuoi"]) - this.ii_OldValue) + this.ii_NewValue;
                    ((DataRowView) this.grdDetail.Rows[e.RowIndex].DataBoundItem).Row["Ps_Co"] = (((decimal) ((DataRowView) this.grdDetail.Rows[e.RowIndex].DataBoundItem).Row["Ps_Co"]) + this.ii_OldValue) - this.ii_NewValue;
                    this.oMethod.ReAllocation(AppInstance.Subsidiary, this.UserDefined1, this.UserDefined2, ((DataRowView) this.grdMaster.CurrentRow.DataBoundItem).Row["Ma_Sp"], ((DataRowView) this.grdDetail.Rows[e.RowIndex].DataBoundItem).Row["Ma_Yt"], this.ii_NewValue);
                }
                else
                {
                    ((DataRowView) this.grdDetail.Rows[e.RowIndex].DataBoundItem).Row["Du_Cuoi"] = this.ii_OldValue;
                }
            }
        }

        private void grdMaster_RowEnter(object sender, DataGridViewCellEventArgs e)
        {
            this.RowMasterIndex = e.RowIndex;
        }

        private void InitializeComponent()
        {
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormProductCosting));
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle7 = new System.Windows.Forms.DataGridViewCellStyle();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle8 = new System.Windows.Forms.DataGridViewCellStyle();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle9 = new System.Windows.Forms.DataGridViewCellStyle();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle10 = new System.Windows.Forms.DataGridViewCellStyle();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle11 = new System.Windows.Forms.DataGridViewCellStyle();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle12 = new System.Windows.Forms.DataGridViewCellStyle();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle13 = new System.Windows.Forms.DataGridViewCellStyle();
            this.txtMa_Sp = new QMVnSoft.Controls.TextSearch();
            this.txtTen_Sp = new QMVnSoft.Controls.TextControl();
            this.lblMa_Sp = new QMVnSoft.Controls.LabelControl();
            this.btnControl2 = new QMVnSoft.Controls.BtnControl();
            this.btnControl3 = new QMVnSoft.Controls.BtnControl();
            this.btnControl4 = new QMVnSoft.Controls.BtnControl();
            this.labelControl1 = new QMVnSoft.Controls.LabelControl();
            this.splitContainer1 = new System.Windows.Forms.SplitContainer();
            this.grdMaster = new QMVnSoft.Controls.GridControl();
            this.Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.Column2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.Column3 = new QMVnSoft.Controls.ChildGridControls.NumericColumn();
            this.Column4 = new QMVnSoft.Controls.ChildGridControls.NumericColumn();
            this.Column5 = new QMVnSoft.Controls.ChildGridControls.NumericColumn();
            this.Column6 = new QMVnSoft.Controls.ChildGridControls.NumericColumn();
            this.Column7 = new QMVnSoft.Controls.ChildGridControls.NumericColumn();
            this.Column8 = new QMVnSoft.Controls.ChildGridControls.NumericColumn();
            this.Column9 = new QMVnSoft.Controls.ChildGridControls.NumericColumn();
            this.Column10 = new QMVnSoft.Controls.ChildGridControls.NumericColumn();
            this.grdDetail = new QMVnSoft.Controls.GridControl();
            this.Column11 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.Column12 = new QMVnSoft.Controls.ChildGridControls.NumericColumn();
            this.Column13 = new QMVnSoft.Controls.ChildGridControls.NumericColumn();
            this.Column14 = new QMVnSoft.Controls.ChildGridControls.NumericColumn();
            this.Column15 = new QMVnSoft.Controls.ChildGridControls.NumericColumn();
            this.Column16 = new QMVnSoft.Controls.ChildGridControls.NumericColumn();
            this.splitContainer1.Panel1.SuspendLayout();
            this.splitContainer1.Panel2.SuspendLayout();
            this.splitContainer1.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.grdMaster)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.grdDetail)).BeginInit();
            this.SuspendLayout();
            // 
            // txtMa_Sp
            // 
            this.txtMa_Sp.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
            this.txtMa_Sp.CheckTextSearched = false;
            this.txtMa_Sp.DisabledForeColor = System.Drawing.Color.Empty;
            this.txtMa_Sp.EmptyIsValid = true;
            this.txtMa_Sp.FieldDisplay = "Ten_Sp";
            this.txtMa_Sp.FirstFilter = "SP_CT = \'S\' AND Loai_Sp = \'K\'";
            this.txtMa_Sp.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtMa_Sp.FoundIsValid = true;
            this.txtMa_Sp.Location = new System.Drawing.Point(77, 13);
            this.txtMa_Sp.MaxLength = 32;
            this.txtMa_Sp.Name = "txtMa_Sp";
            this.txtMa_Sp.OldValue = null;
            this.txtMa_Sp.Size = new System.Drawing.Size(111, 20);
            this.txtMa_Sp.TabIndex = 87;
            this.txtMa_Sp.TableName = "DMSP";
            this.txtMa_Sp.TextDisplay = this.txtTen_Sp;
            this.txtMa_Sp.UserTextLength  = QMVnSoft.AppInstance.TextControlLength.ItemCode;
            this.txtMa_Sp.UserTrimMode  = QMVnSoft.AppInstance.TextControlTrimMode.All;
            this.txtMa_Sp.Value = ((object)(resources.GetObject("txtMa_Sp.Value")));
            // 
            // txtTen_Sp
            // 
            this.txtTen_Sp.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(194)))), ((int)(((byte)(217)))), ((int)(((byte)(247)))));
            this.txtTen_Sp.BorderStyle = System.Windows.Forms.BorderStyle.None;
            this.txtTen_Sp.CheckTextSearched = false;
            this.txtTen_Sp.DisabledForeColor = System.Drawing.Color.Blue;
            this.txtTen_Sp.Enabled = false;
            this.txtTen_Sp.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtTen_Sp.ForeColor = System.Drawing.Color.Blue;
            this.txtTen_Sp.Location = new System.Drawing.Point(194, 16);
            this.txtTen_Sp.Name = "txtTen_Sp";
            this.txtTen_Sp.OldValue = null;
            this.txtTen_Sp.Size = new System.Drawing.Size(231, 13);
            this.txtTen_Sp.TabIndex = 89;
            this.txtTen_Sp.UserTextLength  = QMVnSoft.AppInstance.TextControlLength.None;
            this.txtTen_Sp.UserTrimMode  = QMVnSoft.AppInstance.TextControlTrimMode.Right;
            this.txtTen_Sp.Value = ((object)(resources.GetObject("txtTen_Sp.Value")));
            // 
            // lblMa_Sp
            // 
            this.lblMa_Sp.AutoSize = true;
            this.lblMa_Sp.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblMa_Sp.Location = new System.Drawing.Point(12, 16);
            this.lblMa_Sp.Name = "lblMa_Sp";
            this.lblMa_Sp.Size = new System.Drawing.Size(59, 14);
            this.lblMa_Sp.TabIndex = 88;
            this.lblMa_Sp.Text = "Công đoạn";
            // 
            // btnControl2
            // 
            this.btnControl2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this.btnControl2.Font = new System.Drawing.Font("Arial", 8.25F);
            this.btnControl2.Location = new System.Drawing.Point(673, 12);
            this.btnControl2.Name = "btnControl2";
            this.btnControl2.Size = new System.Drawing.Size(111, 23);
            this.btnControl2.TabIndex = 90;
            this.btnControl2.Text = "&Xóa phân bổ";
            this.btnControl2.UseVisualStyleBackColor = true;
            this.btnControl2.Click += new System.EventHandler(this.btnControl2_Click);
            // 
            // btnControl3
            // 
            this.btnControl3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this.btnControl3.Font = new System.Drawing.Font("Arial", 8.25F);
            this.btnControl3.Location = new System.Drawing.Point(556, 12);
            this.btnControl3.Name = "btnControl3";
            this.btnControl3.Size = new System.Drawing.Size(111, 23);
            this.btnControl3.TabIndex = 90;
            this.btnControl3.Text = "&Cập nhật giá";
            this.btnControl3.UseVisualStyleBackColor = true;
            this.btnControl3.Click += new System.EventHandler(this.btnControl3_Click);
            // 
            // btnControl4
            // 
            this.btnControl4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this.btnControl4.Font = new System.Drawing.Font("Arial", 8.25F);
            this.btnControl4.Location = new System.Drawing.Point(439, 12);
            this.btnControl4.Name = "btnControl4";
            this.btnControl4.Size = new System.Drawing.Size(111, 23);
            this.btnControl4.TabIndex = 90;
            this.btnControl4.Text = "&Tính giá thành";
            this.btnControl4.UseVisualStyleBackColor = true;
            this.btnControl4.Click += new System.EventHandler(this.btnControl4_Click);
            // 
            // labelControl1
            // 
            this.labelControl1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.labelControl1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
            this.labelControl1.Font = new System.Drawing.Font("Arial", 8.25F);
            this.labelControl1.Location = new System.Drawing.Point(-2, 44);
            this.labelControl1.Name = "labelControl1";
            this.labelControl1.Size = new System.Drawing.Size(799, 2);
            this.labelControl1.TabIndex = 91;
            this.labelControl1.Text = "Công đoạn";
            // 
            // splitContainer1
            // 
            this.splitContainer1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                        | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.splitContainer1.IsSplitterFixed = true;
            this.splitContainer1.Location = new System.Drawing.Point(0, 47);
            this.splitContainer1.Name = "splitContainer1";
            this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal;
            // 
            // splitContainer1.Panel1
            // 
            this.splitContainer1.Panel1.Controls.Add(this.grdMaster);
            // 
            // splitContainer1.Panel2
            // 
            this.splitContainer1.Panel2.Controls.Add(this.grdDetail);
            this.splitContainer1.Size = new System.Drawing.Size(796, 487);
            this.splitContainer1.SplitterDistance = 300;
            this.splitContainer1.SplitterWidth = 1;
            this.splitContainer1.TabIndex = 92;
            // 
            // grdMaster
            // 
            this.grdMaster.AllowUserToAddRows = false;
            this.grdMaster.AllowUserToDeleteRows = false;
            this.grdMaster.CheckAutoSize = true;
            this.grdMaster.CheckColor = false;
            this.grdMaster.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
            this.grdMaster.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
            this.Column1,
            this.Column2,
            this.Column3,
            this.Column4,
            this.Column5,
            this.Column6,
            this.Column7,
            this.Column8,
            this.Column9,
            this.Column10});
            this.grdMaster.Dock = System.Windows.Forms.DockStyle.Fill;
            this.grdMaster.Font = new System.Drawing.Font("Arial", 8.25F);
            this.grdMaster.Location = new System.Drawing.Point(0, 0);
            this.grdMaster.Name = "grdMaster";
            this.grdMaster.ReadOnly = true;
            this.grdMaster.Size = new System.Drawing.Size(796, 300);
            this.grdMaster.TabIndex = 0;
            this.grdMaster.RowEnter += new System.Windows.Forms.DataGridViewCellEventHandler(this.grdMaster_RowEnter);
            // 
            // Column1
            // 
            this.Column1.DataPropertyName = "Ma_Sp";
            this.Column1.HeaderText = "Mã sản phẩm";
            this.Column1.Name = "Column1";
            this.Column1.ReadOnly = true;
            this.Column1.Width = 60;
            // 
            // Column2
            // 
            this.Column2.DataPropertyName = "Ten_Sp";
            this.Column2.HeaderText = "Tên sản phẩm";
            this.Column2.Name = "Column2";
            this.Column2.ReadOnly = true;
            this.Column2.Width = 148;
            // 
            // Column3
            // 
            this.Column3.DataPropertyName = "Du_Dau";
            dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
            this.Column3.DefaultCellStyle = dataGridViewCellStyle1;
            this.Column3.HeaderText = "Dở dang đầu kỳ";
            this.Column3.Name = "Column3";
            this.Column3.ReadOnly = true;
            this.Column3.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
            this.Column3.UserTextNumericFormat  = QMVnSoft.AppInstance.TextNumericFormat.LocalAmount;
            this.Column3.Width = 80;
            // 
            // Column4
            // 
            this.Column4.DataPropertyName = "Ps_No";
            dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
            this.Column4.DefaultCellStyle = dataGridViewCellStyle2;
            this.Column4.HeaderText = "Phát sinh trong kỳ";
            this.Column4.Name = "Column4";
            this.Column4.ReadOnly = true;
            this.Column4.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
            this.Column4.UserTextNumericFormat  = QMVnSoft.AppInstance.TextNumericFormat.LocalAmount;
            this.Column4.Width = 80;
            // 
            // Column5
            // 
            this.Column5.DataPropertyName = "So_LuongHT";
            dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
            this.Column5.DefaultCellStyle = dataGridViewCellStyle3;
            this.Column5.HeaderText = "Số lượng hoàn thành";
            this.Column5.Name = "Column5";
            this.Column5.ReadOnly = true;
            this.Column5.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
            this.Column5.UserTextNumericFormat  = QMVnSoft.AppInstance.TextNumericFormat.Quantity;
            this.Column5.Width = 60;
            // 
            // Column6
            // 
            this.Column6.DataPropertyName = "Gia";
            dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
            this.Column6.DefaultCellStyle = dataGridViewCellStyle4;
            this.Column6.HeaderText = "Đơn giá";
            this.Column6.Name = "Column6";
            this.Column6.ReadOnly = true;
            this.Column6.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
            this.Column6.UserTextNumericFormat  = QMVnSoft.AppInstance.TextNumericFormat.LocalPrice;
            this.Column6.Width = 80;
            // 
            // Column7
            // 
            this.Column7.DataPropertyName = "Ps_Co";
            dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
            this.Column7.DefaultCellStyle = dataGridViewCellStyle5;
            this.Column7.HeaderText = "Tổng giá thành";
            this.Column7.Name = "Column7";
            this.Column7.ReadOnly = true;
            this.Column7.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
            this.Column7.UserTextNumericFormat  = QMVnSoft.AppInstance.TextNumericFormat.LocalAmount;
            this.Column7.Width = 80;
            // 
            // Column8
            // 
            this.Column8.DataPropertyName = "So_LuongDD";
            dataGridViewCellStyle6.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
            this.Column8.DefaultCellStyle = dataGridViewCellStyle6;
            this.Column8.HeaderText = "Số lượng dở dang";
            this.Column8.Name = "Column8";
            this.Column8.ReadOnly = true;
            this.Column8.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
            this.Column8.UserTextNumericFormat  = QMVnSoft.AppInstance.TextNumericFormat.Quantity;
            this.Column8.Width = 60;
            // 
            // Column9
            // 
            this.Column9.DataPropertyName = "Ty_Le_Ht";
            dataGridViewCellStyle7.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
            this.Column9.DefaultCellStyle = dataGridViewCellStyle7;
            this.Column9.HeaderText = "%";
            this.Column9.Name = "Column9";
            this.Column9.ReadOnly = true;
            this.Column9.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
            this.Column9.UserTextNumericFormat  = QMVnSoft.AppInstance.TextNumericFormat.Percent;
            this.Column9.Width = 25;
            // 
            // Column10
            // 
            this.Column10.DataPropertyName = "Du_Cuoi";
            dataGridViewCellStyle8.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
            this.Column10.DefaultCellStyle = dataGridViewCellStyle8;
            this.Column10.HeaderText = "Dở dang cuối kỳ";
            this.Column10.Name = "Column10";
            this.Column10.ReadOnly = true;
            this.Column10.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
            this.Column10.UserTextNumericFormat  = QMVnSoft.AppInstance.TextNumericFormat.LocalAmount;
            this.Column10.Width = 80;
            // 
            // grdDetail
            // 
            this.grdDetail.AllowUserToAddRows = false;
            this.grdDetail.AllowUserToDeleteRows = false;
            this.grdDetail.CheckAutoSize = true;
            this.grdDetail.CheckColor = false;
            this.grdDetail.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
            this.grdDetail.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
            this.Column11,
            this.Column12,
            this.Column13,
            this.Column14,
            this.Column15,
            this.Column16});
            this.grdDetail.Dock = System.Windows.Forms.DockStyle.Fill;
            this.grdDetail.Font = new System.Drawing.Font("Arial", 8.25F);
            this.grdDetail.Location = new System.Drawing.Point(0, 0);
            this.grdDetail.Name = "grdDetail";
            this.grdDetail.Size = new System.Drawing.Size(796, 186);
            this.grdDetail.TabIndex = 0;
            this.grdDetail.CellBeginEdit += new System.Windows.Forms.DataGridViewCellCancelEventHandler(this.grdDetail_CellBeginEdit);
            this.grdDetail.CellEndEdit += new System.Windows.Forms.DataGridViewCellEventHandler(this.grdDetail_CellEndEdit);
            // 
            // Column11
            // 
            this.Column11.DataPropertyName = "Ten_Yt";
            this.Column11.HeaderText = "Yếu tố";
            this.Column11.Name = "Column11";
            this.Column11.ReadOnly = true;
            this.Column11.Width = 203;
            // 
            // Column12
            // 
            this.Column12.DataPropertyName = "Du_Dau";
            dataGridViewCellStyle9.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
            this.Column12.DefaultCellStyle = dataGridViewCellStyle9;
            this.Column12.HeaderText = "Đầu kỳ";
            this.Column12.Name = "Column12";
            this.Column12.ReadOnly = true;
            this.Column12.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
            this.Column12.UserTextNumericFormat  = QMVnSoft.AppInstance.TextNumericFormat.LocalAmount;
            this.Column12.Width = 110;
            // 
            // Column13
            // 
            this.Column13.DataPropertyName = "Ps_No";
            dataGridViewCellStyle10.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
            this.Column13.DefaultCellStyle = dataGridViewCellStyle10;
            this.Column13.HeaderText = "Phát sinh";
            this.Column13.Name = "Column13";
            this.Column13.ReadOnly = true;
            this.Column13.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
            this.Column13.UserTextNumericFormat  = QMVnSoft.AppInstance.TextNumericFormat.LocalAmount;
            this.Column13.Width = 110;
            // 
            // Column14
            // 
            this.Column14.DataPropertyName = "Gia";
            dataGridViewCellStyle11.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
            this.Column14.DefaultCellStyle = dataGridViewCellStyle11;
            this.Column14.HeaderText = "Đơn giá";
            this.Column14.Name = "Column14";
            this.Column14.ReadOnly = true;
            this.Column14.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
            this.Column14.UserTextNumericFormat  = QMVnSoft.AppInstance.TextNumericFormat.LocalPrice;
            this.Column14.Width = 110;
            // 
            // Column15
            // 
            this.Column15.DataPropertyName = "Ps_Co";
            dataGridViewCellStyle12.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
            this.Column15.DefaultCellStyle = dataGridViewCellStyle12;
            this.Column15.HeaderText = "Giá thành";
            this.Column15.Name = "Column15";
            this.Column15.ReadOnly = true;
            this.Column15.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
            this.Column15.UserTextNumericFormat  = QMVnSoft.AppInstance.TextNumericFormat.LocalAmount;
            this.Column15.Width = 110;
            // 
            // Column16
            // 
            this.Column16.DataPropertyName = "Du_Cuoi";
            dataGridViewCellStyle13.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
            this.Column16.DefaultCellStyle = dataGridViewCellStyle13;
            this.Column16.HeaderText = "Cuối kỳ";
            this.Column16.Name = "Column16";
            this.Column16.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
            this.Column16.UserTextNumericFormat  = QMVnSoft.AppInstance.TextNumericFormat.LocalAmount;
            this.Column16.Width = 110;
            // 
            // FormProductCosting
            // 
            this.ClientSize = new System.Drawing.Size(796, 534);
            this.Controls.Add(this.splitContainer1);
            this.Controls.Add(this.labelControl1);
            this.Controls.Add(this.btnControl4);
            this.Controls.Add(this.btnControl3);
            this.Controls.Add(this.btnControl2);
            this.Controls.Add(this.txtMa_Sp);
            this.Controls.Add(this.txtTen_Sp);
            this.Controls.Add(this.lblMa_Sp);
            this.MinimumSize = new System.Drawing.Size(802, 566);
            this.Name = "FormProductCosting";
            this.Text = "Chi tiết giá thành sản phẩm";
            this.splitContainer1.Panel1.ResumeLayout(false);
            this.splitContainer1.Panel2.ResumeLayout(false);
            this.splitContainer1.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.grdMaster)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.grdDetail)).EndInit();
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            if (keyData == Keys.Escape)
            {
                base.Close();
            }
            return base.ProcessCmdKey(ref msg, keyData);
        }

        private int RowMasterIndex
        {
            get
            {
                return this.ii_RowMasterIndex;
            }
            set
            {
                if (this.ii_RowMasterIndex != value)
                {
                    this.ii_RowMasterIndex = value;
                    object obj2 = ((DataRowView) this.grdMaster.Rows[this.ii_RowMasterIndex].DataBoundItem).Row["Ma_Sp"];
                    if (!string.IsNullOrEmpty(obj2.ToString()))
                    {
                        DataTable dataSource = this.oMethod.GetDetailTable(AppInstance.Subsidiary, this.UserDefined1, this.UserDefined2, obj2);
                        this.grdDetail.DataSource = new BindingSource(dataSource, dataSource.TableName);
                    }
                    else
                    {
                        this.grdDetail.DataSource = null;
                    }
                }
            }
        }

        public object UserDefined1
        {
            get
            {
                return this.oUserDefined1;
            }
            set
            {
                this.oUserDefined1 = value;
            }
        }

        public object UserDefined2
        {
            get
            {
                return this.oUserDefined2;
            }
            set
            {
                this.oUserDefined2 = value;
            }
        }

        public object UserDefined3
        {
            get
            {
                return this.oUserDefined3;
            }
            set
            {
                this.oUserDefined3 = value;
            }
        }

        public object UserDefined4
        {
            get
            {
                return this.oUserDefined4;
            }
            set
            {
                this.oUserDefined4 = value;
            }
        }
    }
}

